import { ref } from 'vue'
import { defineStore } from 'pinia'
import { getCategory } from '@/api/layout'

export const useCategoryStore = defineStore('category', () => {
    /**
     * 定义数据 state
     */
    const categoryList = ref([])

    /**
     * 定义方法 action
     */
    // 获取一级导航分类
    const getCategoryList = () => {
        getCategory().then(res => {
            categoryList.value = res.result
        })
    }

    return { categoryList, getCategoryList }
})
